<?php if (!defined('THINK_PATH')) exit();?>﻿<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>jOrgChart - A jQuery OrgChart Plugin</title>
        <link rel="stylesheet" href="__APP__/Public/css/common.css" />
    <link rel="stylesheet" href="__APP__/Public/css/public02.css" />
    <link rel="stylesheet" href="__APP__/Public/js/tree/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="__APP__/Public/js/tree/css/jquery.jOrgChart.css"/>
    <link rel="stylesheet" href="__APP__/Public/js/tree/css/custom.css"/>
    <link href="__APP__/Public/js/tree/css/prettify.css" type="text/css" rel="stylesheet" />
 
    <script type="text/javascript" src="__APP__/Public/js/tree/prettify.js"></script>
    
    <!-- jQuery includes -->
    <script type="text/javascript" src="__APP__/Public/js/tree/jquery.min.js"></script>
    <script type="text/javascript" src="__APP__/Public/js/tree/jquery-ui.min.js"></script>
    <link rel='stylesheet' href='__APP__/Public/css/jquery-ui.css' type='text/css' >
    
    <script src="__APP__/Public/js/tree/jquery.jOrgChart.js"></script>
    <script src="__APP__/Public/js/functions.js"></script>
    
 	<style>
logo{ width:814px; height:32px; background:url(__APP__/Public/images/logo.png);  display:inline-block; margin-top:26px; margin-bottom:20px}
	</style>
 </head>

 
  <body>
    <div id="header" class="header">
        <a href="#" class="logo"></a>fff
        <span style="float:right;margin-top: 26px;color: black;"><?php echo L('header_tag1');?><br /><?php echo L('header_tag2');?></span>
    </div>
	   <div class="container02">
        <div class="main">
        	
<div class="preview_confirm_box">
	<?php if(($group == 'visiter') or ($group == 'common') ): ?><a href="/Users/userProfile?uid=<?php echo ($uid); ?>"><?php echo (L("edit")); ?></a>	
		<?php if(($paid == 0) and ($createdby == 2) ): ?>&nbsp;&nbsp; &nbsp;&nbsp;<a href="/Paypal/checkout?uid=<?php echo ($uid); ?>" /><?php echo (L("pay")); ?></a><?php endif; endif; ?>
	
	<?php if(($group == 'agency') and ($confirmed == 0) ): ?><a href="/Users/confirmSave?uid=<?php echo ($uid); ?>"><?php echo (L("confirm_save")); ?></a> &nbsp;&nbsp;&nbsp;&nbsp; 
		<a href="/Users/tempStorage?uid=<?php echo ($uid); ?>"><?php echo (L("just_save")); ?></a> &nbsp;&nbsp;&nbsp;&nbsp;
		<a href="/Users/userProfile?uid=<?php echo ($uid); ?>"><?php echo (L("edit")); ?></a><?php endif; ?>
	
	<?php if($group == 'agency'): if($confirmed == 0): ?><a href="javascript:void(0);" onclick="goback('/Users/userProfile?uid=<?php echo ($uid); ?>');"><?php echo (L("goback")); ?></a>
		<?php else: ?>
			<a href="javascript:void(0);" onclick="goback('/Users/hasconfirmedUserList');"><?php echo (L("goback")); ?></a><?php endif; endif; ?>
</div>
 
 
 <br />
 <div id="userheader">
     <a id='navHome' href="/Users/view?uid=<?php echo ($uid); ?>&type=home"><?php echo (L("home_page")); ?></a>
     <a id='navAlllife' href="/Users/view?uid=<?php echo ($uid); ?>&type=life"><?php echo (L("biography")); ?></a> 
     <a id='navGenealogy' href="/Users/view?uid=<?php echo ($uid); ?>&type=gen"><?php echo (L("genealogy")); ?></a> 
     <a id='navPic' href="/Users/view?uid=<?php echo ($uid); ?>&type=pic"><?php echo (L("my_pics")); ?></a> 
     <a id='navWord' href="/Users/view?uid=<?php echo ($uid); ?>&type=word"><?php echo (L("my_words")); ?></a> 
     <a id='navRemark' href="/Users/view?uid=<?php echo ($uid); ?>&type=remark"><?php echo (L("remark")); ?></a>
     <input id="currNav" type="hidden" value="<?php echo ($currNav); ?>" />
 </div>
 
 <br />
			

	<ul id="org" style="display: none"><?php echo($tree);?></ul>           
    
    <div id="chart" class="orgChart"></div>
    
    <div id="genealogyInfoDialog" style="display: none;">
		<form id="form1"  method="post">
			<input name='opt' type='hidden' value=<?php echo ($opt); ?> />
			<input id='chickedNodeId' name='chickedNodeId' type='hidden' />
			<input id="uid" name="uid" type="hidden" value="<?php echo ($uid); ?>"/>
			<li><?php echo (L("firstname")); ?>:<input id="fname" name="fname" type="text" /></li>
			<li><?php echo (L("lastname")); ?>:<input id="lname" name="lname" type="text" /></li>
			<li><?php echo (L("secondname")); ?>:<input type="text" class="input02" name='secondname'/></li>
			<li><?php echo (L("user_gender")); ?>:<select name="gender">
								<option value="0"><?php echo (L("female")); ?></option>
								<option value="1" selected='selected'><?php echo (L("male")); ?></option>
							</select>
			</li>
			<li><?php echo (L("birthday")); ?>: <input id='birthday' name='birthday' readonly="readonly"  type="text" class='input02'/></li>
			<li><?php echo (L("deathday")); ?>: <input id='deathday' name='deathday' readonly="readonly"  type="text" class='input02'/></li>
			
			<?php if(count($data) == 0): ?><li><?php echo (L("user_name_list")); ?>:
					<select id="node" name="nodeId">
						<option value='0' selected><?php echo (L("empty")); ?></option>
					</select>
				</li>
				<input type='hidden' name='relationship' />
			<?php else: ?>
				<li><?php echo (L("user_name_list")); ?>:
					<select id="node" name="nodeId">
					<?php if(is_array($data)): foreach($data as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
					</select>
				</li>
				<li>
					<?php echo (L("relation")); ?>
					<select id="relationship" name="relationship">
						<option value="0"><?php echo (L("parent")); ?></option>
						<option value="1" selected="selected"><?php echo (L("children")); ?></option>
					</select>
				</li><?php endif; ?>
			<input type='hidden' id="avatar" name='avatar' />
			<input type="submit" value="<?php echo (L("submit")); ?>" />
		</form>
	</div>		
	</div></div>

<script>
	var chickedNodeId = '';
	$(function() {
	    $("#org").jOrgChart({
	        chartElement : '#chart',
	        dragAndDrop  : true,
	        nodeClickCallback: function(node){
	        	$('.orgChart div').css('color', '#fff');
	        	$(node).css('color', 'red');
	        	chickedNodeId = $(node).attr('id');
				$('#chickedNodeId').val(chickedNodeId);
	        }
	    });
	    
	    $("#addNode").click(function(){
	    	showDialog();
	    	$('#form1').attr('action', '__URL__/addGenealogy');
	    });
	    
	    $('#delNode').click(function(){
	    	if (chickedNodeId == '') {
	    		alert('<?php echo (L("pls_select_one")); ?>');
	    		return false;
	    	}
			$.post('__URL__/deleteGenealogyChild', {id:chickedNodeId}, function(data){
				var obj = $.parseJSON(data);
				if (obj.status == 0) {
					alert('<?php echo (L("delete_failed")); ?>');
				} else if (obj.status == 1) {
					//alert('<?php echo (L("delete_success")); ?>');
					location.href = '/Users/genealogy?uid=<?php echo ($uid); ?>&opt=<?php echo ($opt); ?>';
				} else if(obj.status == 2) {
					alert('<?php echo (L("can_only_delete_child_node")); ?>');
				}
			});
	    });
	    
	    $('#editNode').click(function(){
	    	
	    });
	});
	
	function showDialog() {
		$('#genealogyInfoDialog').dialog({
			width: 600,
            height: 420,
            modal: false,
            title: "<?php echo (L("genealogy")); ?>",
            create: function () { },
            open: function () { },
            close: function () { }
		});
		
	}
	
	function getGenealogyData(id) {
		var url = "/Users/getGenealogyInfo";
		$.post(url, {id:id}, function(data){
			var obj = $.parseJSON(data);
			if (obj.status == 1) {
				setField(obj);
			}
		});
	}
	
	function setField(obj) {
		if (obj != null) {
			$('#fname').val(obj.data['firstname']);
			$('#lname').val(obj.data['lastname']);
		}
	}
	
	function finish() {
		location.href = "/Users/userProfile?uid=<?php echo ($uid); ?>&opt=<?php echo ($opt); ?>";
	}
	
</script>
    <!--footer开始-->
    <div id="footer">
        <div class="main">
            <div class="leftside">
                <a href="#">Offrir un Sourire Eternel</a></div>
            
            <div class="leftside ml118">
                <a href="#">｜Qui sommes nous?</a> <a href="#">｜Mentions légales</a> <!-- <a href="/Public/contactUs">｜联系我们</a> -->
            </div>
            <div class="rightside">
                <a href="/Public/FAQ">FAQ</a>
            </div>
            <div class="clear">
            </div>
        </div>
    </div>
    <!--footer结束-->
</body>
</html>